package com.neusoft.lohas.modules.ivm.entity.purchase;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.neusoft.lohas.common.persistence.IdEntity;
import com.neusoft.lohas.modules.ivm.entity.merchant.Merchant;
import com.neusoft.lohas.modules.ivm.entity.order.Order;
import com.neusoft.lohas.modules.ivm.entity.product.Product;

/**
 * 采购指令明细对应的商品采购量Entity
 * 
 * @author Jackie.Liu
 * @version 2015-03-19
 */
@Entity
@Table(name = "ivm_purchase_detail_item")
@DynamicInsert
@DynamicUpdate
public class PurchaseDetailItem extends IdEntity<PurchaseDetailItem>{

	/**
	 * 
	 */
	private static final long serialVersionUID = -4317311625843516720L;
	
	private Merchant merchant; // 所属商户
	private Order order; //采购指令明细对应的订单（仅只订单匹配出来的商品对应的）
	private Product product; // 所属商品
	private Purchase purchase; //对应采购指令
	private int purchaseNumber; //采购总量
	
	public PurchaseDetailItem() {
		super();
	}

	public PurchaseDetailItem(String id) {
		this();
		this.id = id;
	}

	@ManyToOne
	@JoinColumn(name="merchant_id")
	@NotFound(action = NotFoundAction.IGNORE)
	@NotNull(message="归属商户不能为空")
	public Merchant getMerchant() {
		return merchant;
	}

	public void setMerchant(Merchant merchant) {
		this.merchant = merchant;
	}

	@ManyToOne
	@JoinColumn(name = "order_id")
	@NotFound(action = NotFoundAction.IGNORE)
	public Order getOrder() {
		return order;
	}

	public void setOrder(Order order) {
		this.order = order;
	}

	@ManyToOne
	@JoinColumn(name = "product_id")
	@NotFound(action = NotFoundAction.IGNORE)
	@NotNull(message="所属商品不能为空")
	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	@ManyToOne
	@JoinColumn(name="purchase_id")
	@NotFound(action = NotFoundAction.IGNORE)
	public Purchase getPurchase() {
		return purchase;
	}

	public void setPurchase(Purchase purchase) {
		this.purchase = purchase;
	}

	public int getPurchaseNumber() {
		return purchaseNumber;
	}

	public void setPurchaseNumber(int purchaseNumber) {
		this.purchaseNumber = purchaseNumber;
	}
}
